'use strict';

angular.module('app.api', [
    'ui.router',
    'ngResource'
])
.config(function ($stateProvider,$urlRouterProvider) {
    
    $stateProvider
         .state('app.api', {
             abstract: true,
             data: {
                 title: 'api'
             }
         })

       .state('app.api.test', {
           url: '/testapi',
           views: {
               "content@app": {
                   templateUrl: 'app/api/views/test.html',
                   controller: 'ApiTestCtrl'
               }
            },
            
            resolve: {
                orders: function($http, APP_CONFIG){
                    return $http.get(APP_CONFIG.apiRootUrl + '/langs/cn.json')
                }
            },
            
           data: {
               title: 'api'

           }
       })

     .state('app.api.registration', {
         url: '/registration',
         views: {
             "content@app": {
                 templateUrl: 'app/api/views/registration.html',
                 controller: 'RegistrationCtrl'
             }
         },

         resolve: {
             apijson: function ($http, APP_CONFIG) {
                 return $http.get(APP_CONFIG.apiRootUrl + '/user/registration.json')
             },
             returnjson: function ($http, APP_CONFIG) {
                  return $http.get(APP_CONFIG.apiRootUrl + '/return.json')
               }
         },

         data: {
             title: '注册'

         }
     })
         // $urlRouterProvider.otherwise('/inbox/receive');
     //创建公司
      .state('app.api.createcompany', {
         url: '/createcompany',
         views: {
             "content@app": {
                 templateUrl: 'app/api/views/createcompany.html',
                 controller: 'CreateCompanyCtrl'
             }
         },

         resolve: {
             apijsons: function ($http, APP_CONFIG) {
                 return $http.get(APP_CONFIG.apiRootUrl + '/user/createCompany.json')
             },
             returnjsons: function ($http, APP_CONFIG) {
                  return $http.get(APP_CONFIG.apiRootUrl + '/return.json')
               }
         },

         data: {
             title: '创建公司'

         }
      })

     //进入某公司
      .state('app.api.accesscompany', {
          url: '/accesscompany',
          views: {
              "content@app": {
                  templateUrl: 'app/api/views/accesscompany.html',
                  controller: 'AccessCompanyCtrl'
              }
          },

          resolve: {
              apijsons: function ($http, APP_CONFIG) {
                  return $http.get(APP_CONFIG.apiRootUrl + '/user/accesscompany.json')
              },
              returnjsons: function ($http, APP_CONFIG) {
                  return $http.get(APP_CONFIG.apiRootUrl + '/return.json')
              }
          },

          data: {
              title: '邀请参与公司'

          }
      })

        
     //邀请成为公司
      .state('app.api.attendcomp', {
          url: '/attendcomp',
          views: {
              "content@app": {
                  templateUrl: 'app/api/views/attend-comp.html',
                  controller: 'AttendCompCtrl'
              }
          },

          resolve: {
              apijsons: function ($http, APP_CONFIG) {
                  return $http.get(APP_CONFIG.apiRootUrl + '/user/attend-comp.json')
              },
              returnjsons: function ($http, APP_CONFIG) {
                  return $http.get(APP_CONFIG.apiRootUrl + '/return.json')
              }
          },

          data: {
              title: '邀请参与公司'

          }
      })


});